package org.springframework.beans;

import com.h2.util.lang.reflect.ReflectUtils;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import org.springframework.util.Assert;
import org.springframework.util.ReflectionUtils;

public class BeanUtils
{
  public static <T> T convertToBean(String paramString, Class<T> paramClass)
  {
    if (String.class.isAssignableFrom(paramClass))
      return new String(paramString);
    if ((Integer.class.isAssignableFrom(paramClass)) || (Integer.TYPE.isAssignableFrom(paramClass)))
      return new Integer(paramString);
    if ((Long.class.isAssignableFrom(paramClass)) || (Long.TYPE.isAssignableFrom(paramClass)))
      return new Long(paramString);
    if ((Float.class.isAssignableFrom(paramClass)) || (Float.TYPE.isAssignableFrom(paramClass)))
      return new Float(paramString);
    if ((Double.class.isAssignableFrom(paramClass)) || (Double.TYPE.isAssignableFrom(paramClass)))
      return new Double(paramString);
    if ((Boolean.class.isAssignableFrom(paramClass)) || (Boolean.TYPE.isAssignableFrom(paramClass)))
      return new Boolean(paramString);
    return null;
  }

  public static <T> T convertToBean(String paramString1, String paramString2)
  {
    return convertToBean(paramString1, getClass(paramString2));
  }

  public static <T> Class<T> getClass(String paramString)
    throws BeanInstantiationException
  {
    try
    {
      Class localClass = Class.forName(paramString);
      return localClass;
    }
    catch (ClassNotFoundException localClassNotFoundException)
    {
      throw new FatalBeanException("Could not find class: " + paramString, localClassNotFoundException);
    }
  }

  public static <T> T instantiate(Class<T> paramClass)
    throws BeanInstantiationException
  {
    if (paramClass.isInterface())
      throw new BeanInstantiationException(paramClass, "Specified class is an interface");
    try
    {
      Object localObject = paramClass.newInstance();
      return localObject;
    }
    catch (InstantiationException localInstantiationException)
    {
      throw new BeanInstantiationException(paramClass, "Is it an abstract class?", localInstantiationException);
    }
    catch (IllegalAccessException localIllegalAccessException)
    {
      throw new BeanInstantiationException(paramClass, "Is the constructor accessible?", localIllegalAccessException);
    }
  }

  public static <T> T instantiateClass(Class<T> paramClass, Object[] paramArrayOfObject)
    throws BeanInstantiationException
  {
    Assert.notNull(paramClass, "Class must not be null");
    Constructor localConstructor = null;
    try
    {
      localConstructor = ReflectUtils.getConstructor(paramClass, Integer.valueOf(paramArrayOfObject.length));
      Object localObject = localConstructor.newInstance(paramArrayOfObject);
      return localObject;
    }
    catch (InstantiationException localInstantiationException)
    {
      throw new BeanInstantiationException(localConstructor.getDeclaringClass(), "Is it an abstract class?", localInstantiationException);
    }
    catch (IllegalAccessException localIllegalAccessException)
    {
      throw new BeanInstantiationException(localConstructor.getDeclaringClass(), "Is the constructor accessible?", localIllegalAccessException);
    }
    catch (IllegalArgumentException localIllegalArgumentException)
    {
      throw new BeanInstantiationException(localConstructor.getDeclaringClass(), "Illegal arguments for constructor", localIllegalArgumentException);
    }
    catch (InvocationTargetException localInvocationTargetException)
    {
      throw new BeanInstantiationException(localConstructor.getDeclaringClass(), "Constructor threw exception", localInvocationTargetException.getTargetException());
    }
  }

  public static <T> T instantiateClass(Constructor<T> paramConstructor, Object[] paramArrayOfObject)
    throws BeanInstantiationException
  {
    Assert.notNull(paramConstructor, "Constructor must not be null");
    try
    {
      ReflectionUtils.makeAccessible(paramConstructor);
      Object localObject = paramConstructor.newInstance(paramArrayOfObject);
      return localObject;
    }
    catch (InstantiationException localInstantiationException)
    {
      throw new BeanInstantiationException(paramConstructor.getDeclaringClass(), "Is it an abstract class?", localInstantiationException);
    }
    catch (IllegalAccessException localIllegalAccessException)
    {
      throw new BeanInstantiationException(paramConstructor.getDeclaringClass(), "Is the constructor accessible?", localIllegalAccessException);
    }
    catch (IllegalArgumentException localIllegalArgumentException)
    {
      throw new BeanInstantiationException(paramConstructor.getDeclaringClass(), "Illegal arguments for constructor", localIllegalArgumentException);
    }
    catch (InvocationTargetException localInvocationTargetException)
    {
      throw new BeanInstantiationException(paramConstructor.getDeclaringClass(), "Constructor threw exception", localInvocationTargetException.getTargetException());
    }
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     org.springframework.beans.BeanUtils
 * JD-Core Version:    0.6.2
 */